package com.xinzhi.service.impl;

import com.xinzhi.mapper.AppraisalssMapper;
import com.xinzhi.mapper.KouFenShenHeMapper;
import com.xinzhi.pojo.dto.KouFenShenHe;
import com.xinzhi.service.KouFenShenHeService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KouFenShenHeServiceImpl implements KouFenShenHeService {

    @Autowired
    private KouFenShenHeMapper kouFenShenHeMapper;



    /**
     * 特殊扣分审核的查询接口
     * @return
     */
    @Override
    public List<KouFenShenHe> selectAllssss() {
        List<KouFenShenHe> kouFenShenHes = kouFenShenHeMapper.selectKou();
        return kouFenShenHes;
    }

    /**
     * 特殊扣分审核根据发布状态的查询接口
     * @param publishstatus
     * @return
     */
    @Override
    public Result selectKouByPublishstatus(String publishstatus) {
        if (publishstatus == null){
            return Result.error("状态不能为空");
        }
        List<KouFenShenHe> kouFenShenHes = kouFenShenHeMapper.selectKouByPublishstatus(publishstatus);
        return kouFenShenHes != null ? Result.ok(kouFenShenHes) : Result.error("查询失败");
    }
    //特殊扣分审核根据状态查询接口
    @Override
    public Result selectKouByPublish(String publishstatus) {
        List<KouFenShenHe> kouFenShenHes = kouFenShenHeMapper.selectKouByPublish(publishstatus);
        return Result.ok(kouFenShenHes) ;
    }


    /**
     * 特殊扣分审核根据年份的查询接口
     * @param yearnumber
     * @return
     */

    @Override
    public Result selectKouByYearnumber(String yearnumber) {
        if (yearnumber == null){
            return Result.error("年份不能为空");
        }
        List<KouFenShenHe> kouFenShenHes = kouFenShenHeMapper.selectKouByYearnumber(yearnumber);
        return kouFenShenHes != null ? Result.ok(kouFenShenHes) : Result.error("查询失败");
    }


    /**
     * 特殊扣分审核的删除接口
     * @param deleted
     * @return
     */

    @Override
    public Result deleteupdate(String demerit,Integer deleted) {
       if (demerit == null && deleted == 0){
           return Result.error("参数不能为空");
       }
        int deleteupdate = kouFenShenHeMapper.deleteupdate(demerit, deleted);
        return deleteupdate > 0 ? Result.ok("删除成功") : Result.error("删除失败");
    }
}
